package board.interceptor;

import board.action.BoardServiceAware;
import board.model.*;
import com.opensymphony.xwork2.*;
import com.opensymphony.xwork2.interceptor.*;

public class BoardServiceInterceptor extends AbstractInterceptor {
	private BoardService boardService;

	public void init() {
		boardService = new BoardService();
	}

	public String intercept(ActionInvocation invocation) throws Exception {
		Object action = invocation.getAction();
		if (action instanceof BoardServiceAware) {
			BoardServiceAware aware = (BoardServiceAware) action;
			aware.setBoardService(boardService);
		}
		return invocation.invoke();
	}

	public void destroy() {
		boardService = null;
	}
}